Making graphs in R (I)
ggplot2ggplot2ggplot2 package (the grammar of graphs theory)
dataaestheticsgeometrylayers in our graphdatacountry | continent | year | lifeExp | pop | gdpPercap |
|---|---|---|---|---|---|
Brazil | Americas | 1,952 | 50.917 | 56,602,560 | 2,108.944 |
Brazil | Americas | 1,957 | 53.285 | 65,551,171 | 2,487.366 |
Brazil | Americas | 1,962 | 55.665 | 76,039,390 | 3,336.586 |
Brazil | Americas | 1,967 | 57.632 | 88,049,823 | 3,429.864 |
Brazil | Americas | 1,972 | 59.504 | 100,840,058 | 4,985.711 |
dataggplot function, so it can plot it!aestheticsgeometrylabsthemescales & geom## Plotting the mroe layers for out plot!
gapminder_brazil |>
ggplot(aes(x = year, y = lifeExp)) +
geom_point() +
labs(title = 'Life expectancy evolution in Brazil',
subtitle = 'From 1952 to 2007',
x = 'Years',
y = 'Life expectancy(age)',
caption = 'Source: gapminder dataset') +
theme_light() +
scale_x_continuous(breaks = seq(1952, 2007, by = 5)) +
geom_line()ggplot2: before & after 9 lines!ggplot2 creates graph in a layers mentalityPolicy Analytics Credential